package test;

import java.awt.Color;
import java.util.LinkedList;

public class Polygon {
	String name;
	LinkedList<Coordinate> v = new LinkedList<Coordinate>(); // vortice list
	Color color;

	public Polygon(String name, LinkedList<Coordinate> v) {
		this.name = name;
		this.v = v;
	}

	public Polygon(String name, LinkedList<Coordinate> v, Color c) {
		this.name = name;
		this.v = v;
		this.color = c;
	}

	public LinkedList<Coordinate> getV() {
		return v;
	}

	public String getName() {
		return name;
	}

	public String coordinateList() {
		String s = "";
		for (Coordinate c : v) {
			s = s + " " + c.toString();
		}

		return s;
	}

	@Override
	public String toString() {
		return name + ": " + coordinateList();
	}

	public int[] getXArray() {
		int[] xArray = new int[v.size()];
		for (int i = 0; i < v.size(); i++) {
			xArray[i] = v.get(i).getX();
		}
		return xArray;
	}

	public int[] getYArray() {
		int[] yArray = new int[v.size()];
		for (int i = 0; i < v.size(); i++) {
			yArray[i] = v.get(i).getY();
		}
		return yArray;
	}

	public Color getColor() {
		return color;
	}
	
	public String getColorString(){
		return ("(" + color.getRed() + "," +color.getGreen() + "," + color.getBlue() + ")");
	}
}
